package servlet;

import com.ncist.dao.UserDao;
import com.ncist.pojo.User;
import com.ncist.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@WebServlet("/logform")
public class loginservlet extends HttpServlet
{
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        String name = request.getParameter("uname");
        String pwd = request.getParameter("upwd");

        String flag1 = null;
        SqlSession sqlSession;
        sqlSession = MybatisUtils.getSqlSession();
        UserDao mapper = sqlSession.getMapper(UserDao.class);
//        System.out.println("赋值前" + flag1 + name + pwd);
        flag1 = mapper.select(name, pwd);
//        System.out.println("赋值后" + flag1);

        //关闭sqlSession
        sqlSession.close();
        request.setAttribute("flag1", flag1);
        request.getRequestDispatcher("/index.jsp").forward(request, response);
    }
}
